<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

<%
	String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>selectchannel.jsp</title>
	<link href="./css/xtab.css" rel="stylesheet" type="text/css" />
 

  </head>
  
  <body>
  <html:form action="/channel.do">
  
  <table align="center" width="50%" cellspacing="0">
			<tr>
				<th class="tableTitle">
					 <input type="checkbox" name="allchannel" onclick="checkAll('channel');">
				</th>
				<th class="tableTitle">
					频道
				</th>
				 
			 
			</tr>
			<logic:iterate id="s" name="list" indexId="index">
				<tr>
					<td class="tableElement">
						<input type="checkbox" name="channel" value="${s.channelId }">
						<input type="hidden" id="channelName_${index }" value="${s.channelName }">
					</td>
				
					<td class="tableElement">
						${s.channelName }
					</td>
					 
				</tr>
			</logic:iterate>
		</table>
		<br>
   <div align="center">
    <input type="button" value="确 定" class="button" name="ok" onclick="comfirmSelect();">
     <input type="button" value="取消" class="button" name="cancel" onclick="cancelSelect();">
     </div>
    <script>
     
      function comfirmSelect(){
      
        var strId="";
          var strName="";
           var roomids = document.getElementsByName("channel");  
           for (var j = 0; j < roomids.length; j++) {
              if(roomids.item(j).checked == true){  
              	   strId+=roomids.item(j).value+",";
              	   strName+=document.getElementById("channelName_"+j).value+",";
              }   
          }
          if(strName==""){
          	alert("请至少选择一项");
          	return false;
          }else{
           	window.opener.document.getElementById("channelName").value=strName.substring(0,strName.length-1);
        	window.opener.document.getElementById("channel").value=strId.substring(0,strId.length-1);
      		window.close();
          } 
       
      }
      function cancelSelect(){
      	window.close();
      }
	function checkAll(formvalue) {  
            var roomids = document.getElementsByName(formvalue);  
           for (var j = 0; j < roomids.length; j++) {
              if(document.getElementsByName('allchannel')[0].checked==true){
              	roomids.item(j).checked = true;  
              }   
              else{
              	roomids.item(j).checked = false;  
              }   
          }  
        }
    </script>
    </html:form>
  </body>
</html:html>
